/*
 * @lc app=leetcode.cn id=11 lang=javascript
 *
 * [11] 盛最多水的容器
 */

// @lc code=start
/**
 * @param {number[]} height
 * @return {number}
 */
var maxArea = function (height) {
  const n = height.length;
  let i = 0;
  let j = n - 1;
  let max = 0;
  let size = 0;
  while (i < j) {
    size = Math.min(height[i], height[j]) * (j - i);
    max = Math.max(size, max);
    if (height[i] > height[j]) j--;
    else i++;
  }
  return max;
};
// @lc code=end
